package com.mvp.shq.washer.http;


import com.mvp.shq.washer.entity.BasicInfo;
import com.mvp.shq.washer.entity.OrderInfo;
import com.mvp.shq.washer.entity.RechargeBean;
import com.mvp.shq.washer.entity.WxPayBean;
import com.mvp.shq.washer.entity.result.AliPay;
import com.mvp.shq.washer.entity.result.AlipayResult;
import com.mvp.shq.washer.entity.Banner;
import com.mvp.shq.washer.entity.result.BaseResult;
import com.mvp.shq.washer.entity.result.BillResult;
import com.mvp.shq.washer.entity.result.CouponResult;
import com.mvp.shq.washer.entity.result.MsgResult;
import com.mvp.shq.washer.entity.OrderResponse;
import com.mvp.shq.washer.entity.RechargeMoney;
import com.mvp.shq.washer.entity.RechargeResponse;
import com.mvp.shq.washer.entity.TokenBean;
import com.mvp.shq.washer.entity.User;
import com.mvp.shq.washer.entity.VersionBean;
import com.mvp.shq.washer.entity.result.OrderResult;
import com.mvp.shq.washer.entity.result.WasherInfoResult;
import com.mvp.shq.washer.entity.result.WxPayResult;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Path;
import retrofit2.http.Query;

/**
 * Created by Administrator on 2016/3/23.
 */
public interface ApiService {

    /**
     * 登录接口
     *
     * @param mobile
     * @param pwd
     * @return
     */
    @POST("m/login/anon")
    Observable<BaseResult<TokenBean>> login(@Query("mobile") String mobile, @Query("pwd") String pwd, @Query("timestamp") String timestamp, @Query("sign") String sign);

    /**
     * 注册
     * @param mobile
     * @param pwd
     * @param code
     * @param timestamp
     * @param sign
     * @return
     */
    @POST("m/register/anon")
    Observable<BaseResult<TokenBean>> reg(@Query("mobile")String mobile,@Query("pwd")String pwd,@Query("code")String code,@Query("timestamp")String timestamp,@Query("sign")String sign);

    /**
     * 获取注册验证码
     * @param mobile
     * @return
     */
    @GET("m/register/code/anon")
    Observable<BaseResult<String>> code(@Query("mobile")String mobile);

    /**
     * 忘记密码
     * @param mobile
     * @param code
     * @param pwd
     * @param timestamp
     * @param sign
     * @return
     */
    @POST("m/forget/anon")
    Observable<BaseResult<String>> forgetPwd(@Query("mobile")String mobile,@Query("code")String code,@Query("pwd")String pwd,@Query("timestamp")String timestamp,@Query("sign")String sign);

    /**
     * 获取忘记密码验证码
     * @param mobile
     * @return
     */
    @GET("m/forget/code/anon")
    Observable<BaseResult<String>> forgetCode(@Query("mobile")String mobile);

    /**
     * 获取用户信息
     * @param token
     * @param userId
     * @return
     */
    @GET("m/info/{userId}")
    Observable<BaseResult<User>> getUserInfo(@Header("Authorization") String token,@Path("userId") String userId);

    /**
     * 获取banner
     * @return
     */
    @GET("m/banners/anon")
    Observable<BaseResult<List<Banner>>> banner();

    /**
     * 获取充值金额
     * @return
     */
    @GET("m/recharge/money/anon")
    Observable<BaseResult<List<RechargeMoney>>> rechargeMoney();

    /**
     * 获取充值金额  送钱
     * @return
     */
    @GET("m/recharge/money/anon")
    Observable<BaseResult<List<RechargeBean>>> getRechargeMoney();

    /**
     * 获取版本号
     * @param platform
     * @return
     */
    @GET("m/versions/latest/anon")
    Observable<BaseResult<VersionBean>> version(@Query("platform")String platform);

    /**
     * 修改密码
     * @param token
     * @param userId
     * @param oldPwd
     * @param newPwd
     * @return
     */
    @PUT("m/info/{userId}/pwd")
    Observable<BaseResult<String>> resetPwd(@Header("Authorization") String token,@Path("userId") String userId,@Query("oldPwd")String oldPwd,@Query("newPwd")String newPwd);

    /**
     * 获取消息列表
     * @param token
     * @param userId
     * @return
     */
    @GET("m/messages/user/{userId}")
    Observable<BaseResult<MsgResult>> getMessages(@Header("Authorization") String token, @Path("userId") String userId, @Query("pageNo")int pageNo, @Query("pageSize")int pageSize);

    /**
     * 修改用户生日
     * @param token
     * @param userId
     * @param birthday
     * @return
     */
    @PUT("m/info/{userId}/birthday")
    Observable<BaseResult<String>> updateBirthday(@Header("Authorization") String token, @Path("userId") String userId, @Query("birthDay")String birthday);

    /**
     * 修改用户性别
     * @param token
     * @param userId
     * @param gender
     * @return
     */
    @PUT("m/info/{userId}/gender")
    Observable<BaseResult<String>> updateGender(@Header("Authorization") String token, @Path("userId") String userId, @Query("gender")String gender);

    /**
     * 修改用户昵称
     * @param token
     * @param userId
     * @param nickname
     * @return
     */
    @PUT("m/info/{userId}/nickname")
    Observable<BaseResult<String>> updateNickname(@Header("Authorization") String token, @Path("userId") String userId, @Query("nickname")String nickname);

    /**
     * 上传用户头像
     * @param token
     * @param userId
     * @param head
     * @return
     */
    @Multipart
    @POST("m/info/{userId}/face")
    Observable<BaseResult<String>> updateFace(@Header("Authorization") String token, @Path("userId") String userId,@Part("face\"; filename=\"image.png") RequestBody head);

    /**
     *修改手机号码发送验证码
     * @param token
     * @param mobile
     * @return
     */
    @GET("m/mod/code")
    Observable<BaseResult<String>> modifyMobileCode(@Header("Authorization") String token,@Query("mobile")String mobile);

    /**
     * 修改手机
     * @param token
     * @param userId
     * @param oldPwd
     * @param newMobile
     * @param code
     * @return
     */
    @PUT("m/info/{userId}/mobile")
    Observable<BaseResult<String>> modifyMobile(@Header("Authorization") String token,@Path("userId")String userId,@Query("oldPwd")String oldPwd,@Query("newMobile")String newMobile,@Query("code")String code);

    /**
     * 分享回调
     * @param userId
     * @param userMobile
     * @param shareType
     * @return
     */
    @POST("m/share/records/save/anon")
    Observable<BaseResult<String>> shareRecord(@Query("userId")String userId,@Query("userMobile")String userMobile,@Query("shareType")String shareType);

    /**
     * 获取洗衣机信息
     * @param token
     * @param washerNo
     * @param washerType
     * @return
     */
    @GET("m/washers/washerInfo")
    Observable<BaseResult<WasherInfoResult>> washerInfo(@Header("Authorization") String token,@Query("washerNo")String washerNo);

    /**
     * 获取今日分享次数
     * @param token
     * @param userId
     * @return
     */
    @POST("m/share/records/today/count")
    Observable<BaseResult<Integer>> shareCount(@Header("Authorization") String token,@Query("userId")String userId);

    /**
     * 获取支付宝支付参数
     * @param token
     * @param orderNo
     * @return
     */
    @GET("m/pays/getSign")
    Observable<BaseResult<String>> getSign(@Header("Authorization") String token,@Query("orderNo")String orderNo);

    /**
     * 获取优惠券列表
     * @param token
     * @param userId
     * @return
     */
    @GET("m/coupons")
    Observable<BaseResult<CouponResult>> coupons(@Header("Authorization") String token, @Query("userId")String userId, @Query("pageNo")int pageNo, @Query("pageSize")int pageSize);

    /**
     *订单支付
     * @param token
     * @param orderDto
     * @return
     */
    @POST("m/order")
    Observable<BaseResult<AliPay>> alipayOrder(@Header("Authorization") String token, @Body OrderResponse orderDto);
    /**
     *微信支付
     * @param token
     * @param orderDto
     * @return
     */
    @POST("m/order")
    Observable<BaseResult<WxPayResult>> wxOrder(@Header("Authorization") String token, @Body OrderResponse orderDto);

    /**
     * 支付宝充值
     * @param token
     * @param rechargeDto
     * @return
     */
    @POST("m/recharge")
    Observable<BaseResult<AlipayResult>> recharge(@Header("Authorization") String token, @Body RechargeResponse rechargeDto);
    /**
     * 微信充值
     * @param token
     * @param rechargeDto
     * @return
     */
    @POST("m/recharge")
    Observable<BaseResult<WxPayBean>> wxRecharge(@Header("Authorization") String token, @Body RechargeResponse rechargeDto);

    /**
     * 获取订单信息
     * @param token
     * @param orderNo
     * @return
     */
    @GET("m/order/getOrderByOrderNo")
    Observable<BaseResult<OrderInfo>> orderInfo(@Header("Authorization") String token,@Query("orderNo")String orderNo);

    /**
     * 获取订单列表
     * @param token
     * @param userId
     * @return
     */
    @GET("m/order/getOrderByUserId")
    Observable<BaseResult<OrderResult>> orders(@Header("Authorization") String token, @Query("userId")String userId,@Query("pageNo")int pageNo,@Query("pageSize")int pageSize);

    /**
     * 提现
     * @param token
     * @param userId
     * @param money
     * @param realName
     * @param account
     * @param sign
     * @return
     */
    @POST("m/pay/withdraw")
    Observable<BaseResult<String>> withDraw(@Header("Authorization") String token, @Query("userId")String userId, @Query("money")BigDecimal money,@Query("realName")String realName,@Query("account")String account,@Query("sign")String sign);

    /**
     * 获取支付明细
     * @param token
     * @param userId
     * @return
     */
    @GET("m/account")
    Observable<BaseResult<BillResult>> getBill(@Header("Authorization") String token,@Query("userId")String userId,@Query("pageNo")int pageNo,@Query("pageSize")int pageSize);

    /**
     * 意见反馈
     * @param token
     * @param message
     * @param photos
     * @return
     */
    @Multipart
    @POST("m/feedback")
    Observable<BaseResult<String>> feedBack(@Header("Authorization") String token,@Query("userId")String userId, @Query("message")String message,@PartMap Map<String,RequestBody> photos);

    /**
     * 故障反馈
     * @param token
     * @param userId
     * @param washerNo
     * @param content
     * @return
     */
    @POST("m/washers/problem")
    Observable<BaseResult<String>> faultFeedBack(@Header("Authorization") String token,@Query("userId")String userId,@Query("washerNo")String washerNo,@Query("problemContent")String content);

    /**
     * 获取基础信息
     * @param key
     * @return
     */
    @GET("m/basicInfo/anon")
    Observable<BaseResult<BasicInfo>> basicInfo(@Query("key")String key);

    /**
     *获取当前正在进行中的订单
     * @param token
     * @param userId
     * @return
     */
    @GET("m/order/getStatusByUserId")
    Observable<BaseResult<OrderInfo>> getOrderBuUserId(@Header("Authorization") String token,@Query("userId")String userId);

    /**
     * 获取洗涤剩余时间
     * @param token
     * @param orderNo
     * @return
     */
    @GET("m/washers/rest")
    Observable<BaseResult<Integer>> getRestTime(@Header("Authorization") String token,@Query("orderNo")String orderNo);

    /**
     * 设置订单为异常订单
     * @param token
     * @param orderNo
     * @return
     */
    @PUT("m/order/setOrderError")
    Observable<BaseResult<String>> setErrorOrder(@Header("Authorization") String token,@Query("orderNo")String orderNo);

    /**
     * 申请退款
     * @param token
     * @param userId
     * @param orderNo
     * @param content
     * @return
     */
    @POST("m/refund/")
    Observable<BaseResult<String>> refund(@Header("Authorization") String token,@Query("userId")String userId,@Query("orderNo")String orderNo,@Query("reason")String content);
}
